home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / gold / indivClass.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  4.5 KB  |  138 lines

  1. /*
  2.  * The original copyright owners of the accompanying source code files have
  3.  * agreed to place such code into the public domain.  Accordingly, anyone
  4.  * who receives or obtains a copy of such source code is freely entitled to
  5.  * reproduce, use and otherwise exploit such code (including the right to
  6.  * make derivative works), at his/her own risk and expense, without any
  7.  * obligation or liability to the original copyright owners.
  8.  *
  9.  * We would appreciate (but do not require) that the following message be
  10.  * included in any derivative works:
  11.  *
  12.  * "Portions of this program were developed by Peter Broadwell, Rob Myers
  13.  * and Robin Schaufler while working in Silicon Valley."
  14.  *
  15.  * The accompanying source code files and related documentation materials
  16.  * are distributed on an "AS IS" basis, without any warranties or
  17.  * guarantees of any kind.  All implied warranties, including the implied
  18.  * warranties of merchantability and of fitness for any particular purpose,
  19.  * are expressly disclaimed.
  20.  */
  21. #include "gl.h"
  22.  
  23. #include "geom.h"
  24. #include "class.h"
  25. #include "classIds.h"
  26. #include "selectors.h"
  27. #include "mbox.h"
  28. #include "individual.h"
  29. #include "colors.h"
  30.  
  31. extern class mboxClass;
  32.  
  33. extern char *replicateModel(), *serviceTic(), *moveUp(), *drawIndividual();
  34. extern char *freeIndividual(), *selectIndiv(), *deselectIndiv();
  35. extern char *bselIndividual(), *cselIndividual();
  36. extern char *eselIndividual(), *oselIndividual(), *nselIndividual();
  37. extern char *postIndividual(), *dieIndividual(), *addPanel();
  38.  
  39. fcnTable indivTable[] = {
  40.     INIT,    replicateModel,    /* instantiate and initialize the model */
  41.     DOIT,       serviceTic,    /* service the individual's tic, by servicing */
  42.                 /* each of its behaviors */
  43.     MOVE,    moveUp,        /* advance to next position and heading */
  44.     DRAW,    drawIndividual,    /* render the model description */
  45.     FREE,    freeIndividual,    /* unsubscribe and gffree indiv & his pals */
  46.     SELECT,    selectIndiv,    /* process selection of an individual   */
  47.     DESELECT,    deselectIndiv,    /* process deselection of an individual */
  48.     BEGINSELECT,bselIndividual,    /* begin picking on an individual       */
  49.     CONTSELECT,    cselIndividual,    /* continue picking on an individual    */
  50.     ENDSELECT,    eselIndividual,    /* end picking on an individual         */
  51.     OLDSELECT,    oselIndividual,    /* no longer picking on an individual   */
  52.     NEWSELECT,    nselIndividual,    /* continue picking on a new individual */
  53.     ADDPANEL,    addPanel,    /* add a panel for the individual    */
  54.     POSTBEHAVE,    postIndividual,    /* post a behavior to an individual    */
  55.     DIE,    dieIndividual,
  56.     EOTABLE,
  57. };
  58.  
  59. class indivClass = {
  60.     &mboxClass,
  61.     indivTable,
  62.     sizeof(individual),
  63.     INDIVIDUAL,
  64. };
  65.  
  66. individual indivTemplate = {
  67.             /*   inst        */
  68.     &indivClass,    /* myClass pointer    */
  69.     NULL,        /* classFunctions     */
  70.     0,            /* nFunctions        */
  71.             /*   mailbox        */
  72.     NULL,        /* subscribers          */
  73.     NULL,        /* subscribedTo         */
  74.                 /*   individual         */
  75.     {0,0,0},        /* position        */
  76.     {0,0,0},        /* lastPosition        */
  77.     {1,0,0},        /* delta        */
  78.     {0,0,0},        /* velocity        */
  79.     {0,0,0},        /* avelocity        */
  80.     {3,5,4},        /* acceleration        */
  81.     1.0,        /* speed        */
  82.     {3,4,5},        /* heading        */
  83.     {0,0,0},        /* rotation        */
  84.     {0,0,0},        /* influence        */
  85.     0.0,        /* scale        */
  86.     NULL,        /* model        */
  87.     NULL,        /* flags        */
  88.     NULL,        /* curVars        */
  89.     NULL,        /* controls        */
  90. };
  91.  
  92. point selectPoints[] = {
  93.     {    0,    0,    0, },    /* gratuitous vertex 0 */
  94.     {    0,  000,    0, },
  95.     {   10,  000,  -30, },
  96.     {   50,  000,  -30, },
  97.     {   25,  000,  -50, },
  98.     {   30,  000,  -90, },
  99.     {    0,  000,  -70, },
  100.     {  -30,  000,  -90, },
  101.     {  -25,  000,  -50, },
  102.     {  -50,  000,  -30, },
  103.     {  -10,  000,  -30, },
  104. };
  105.         /* null terminated polys, double null at end */
  106. long selectVertices[] = {
  107.     2,4,6,8,10,0,
  108.     2,3,4,0,
  109.     4,5,6,0,
  110.     6,7,8,0,
  111.     8,9,10,0,
  112.     10,1,2,0,
  113.     2,1,10,0,
  114.     10,9,8,0,
  115.     8,7,6,0,
  116.     6,5,4,0,
  117.     4,3,2,0,
  118.     10,8,6,4,2,0,
  119.     0,
  120. };
  121.  
  122. model selectModel = {
  123.     NULL,            /* next model segment          */
  124.     NULL,            /* child model segments        */
  125.     0,                /* geometry compiled yet?      */
  126.     0,                /* compiled geometry object Id */
  127.     selectPoints,        /* point dictionary            */
  128.     selectVertices,         /* polygon descriptions        */
  129.     { 0,0,0},            /* centroid                    */
  130.     SELECT_COLOR,        /* color                       */
  131.     SELECT_TEXTURE,        /* texture                     */
  132.     FALSE,            /* outlined                    */
  133.     { 0,0,0},            /* rotation                    */
  134.     { 750,0,200},        /* translation                 */
  135.     {1.0,1.0,1.0},        /* scale                       */
  136.     0,                /* declasse               */
  137. };
  138.